package c.c.b.b.d;

import android.os.SystemClock;
import c.c.b.b.f.p.a;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/* compiled from: RequestFuture */
public class p<T> implements a<T>, Future<c.c.b.b.f.p<T>> {
    public boolean a = false;
    public c.c.b.b.f.p<T> b;

    public final synchronized c.c.b.b.f.p<T> a(Long l) throws InterruptedException, TimeoutException {
        if (this.a) {
            return this.b;
        }
        if (l == null) {
            while (!isDone()) {
                wait(0);
            }
        } else if (l.longValue() > 0) {
            long uptimeMillis = SystemClock.uptimeMillis();
            long longValue = l.longValue() + uptimeMillis;
            while (!isDone() && uptimeMillis < longValue) {
                wait(longValue - uptimeMillis);
                uptimeMillis = SystemClock.uptimeMillis();
            }
        }
        if (this.a) {
            return this.b;
        }
        throw new TimeoutException();
    }

    public synchronized void b(c.c.b.b.f.p<T> pVar) {
        this.a = true;
        this.b = pVar;
        notifyAll();
    }

    /* renamed from: c */
    public c.c.b.b.f.p<T> get() throws InterruptedException {
        try {
            return a(null);
        } catch (TimeoutException e) {
            throw new AssertionError(e);
        }
    }

    public synchronized boolean cancel(boolean z) {
        return false;
    }

    public boolean isCancelled() {
        return false;
    }

    public synchronized boolean isDone() {
        return this.a;
    }

    public Object get(long j, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
        return a(Long.valueOf(TimeUnit.MILLISECONDS.convert(j, timeUnit)));
    }

    public synchronized void a(c.c.b.b.f.p<T> pVar) {
        this.a = true;
        this.b = pVar;
        notifyAll();
    }
}
